package com.loubobooo.personal.blog.controller.portal;

import com.loubobooo.personal.blog.entity.Link;
import com.loubobooo.personal.blog.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;

@Controller public class LinkController {
    @Autowired private LinkService linkService;

    @RequestMapping("/applyLink") public ModelAndView applyLinkView() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("Home/Page/applyLink");
        return modelAndView;
    }

    @RequestMapping(value = "/applyLinkSubmit", method = {
            RequestMethod.POST })
    public void applyLinkSubmit(Link link) {
        Date date = new Date();
        link.setLinkStatus(0);
        link.setLinkCreateTime(date);
        link.setLinkUpdateTime(date);
        linkService.insertLink(link);
    }
}
